var a = getApp();

Page({
    data: {
        teamName: "",
        teamId: "",
        teamAdmin: "0",
        teamInfo: "",
        logo: "",
        memberCount: "",
        todayDan: "",
        todayNew: ""
    },
    loadData: function() {
        var t = this;
        a.network.post({
            url: a.url.teamInfo,
            params: {
                id: t.data.teamId
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(e) {
                1 == e.data.result ? (t.showTeamData(e.data.data.teamInfo), wx.setStorageSync(a.storage.teamInfo, e.data.data.teamInfo)) : a.util.showToast(e.data.message);
            },
            fail: function() {
                a.util.showToast("获取团队信息失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    loadTeamcheduleData: function() {
        var t = this;
        a.network.post({
            url: a.url.teamScheduleInfo,
            params: {
                teamId: t.data.teamId
            },
            before: function() {
                wx.showNavigationBarLoading();
            },
            success: function(e) {
                1 == e.data.result ? t.setData({
                    memberCount: e.data.data.memberCount,
                    todayDan: e.data.data.todayDan,
                    todayNew: e.data.data.todayNew
                }) : a.util.showToast(e.data.message);
            },
            fail: function() {
                a.util.showToast("获取团队信息失败");
            },
            complete: function() {
                wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
            }
        });
    },
    showTeamData: function(a) {
        console.log("aa", a), a && this.setData({
            teamName: a.name,
            logo: a.logo
        });
    },
    bindNewDanClick: function(a) {
        wx.navigateTo({
            url: "teamNewSchedule/teamNewSchedule?teamId=" + this.data.teamId
        });
    },
    bindHaveDanClick: function(a) {
        wx.navigateTo({
            url: "teamHaveSchedule/teamHaveSchedule?teamId=" + this.data.teamId
        });
    },
    bindMemberClick: function(a) {
        wx.navigateTo({
            url: "teamMember/teamMember?teamId=" + this.data.teamId
        });
    },
    bindTeamPageTap: function(t) {
        a.util.navToTeamHome(this.data.teamId);
    },
    bindEditInfoTap: function(a) {
        wx.navigateTo({
            url: "teamInfo/teamInfo?teamId=" + this.data.teamId
        });
    },
    bindRankTap: function(a) {
        wx.navigateTo({
            url: "teamOrderRank/teamOrderRank?teamId=" + this.data.teamId
        });
    },
    bindTeamInviteTap: function(a) {
        wx.navigateTo({
            url: "teamInvite/teamInvite?teamId=" + this.data.teamId
        });
    },
    bindTeamMemberOrderTap: function(a) {
        wx.navigateTo({
            url: "teamMemberOrder/teamMemberOrder?teamId=" + this.data.teamId
        });
    },
    bindTeamMemberManageTap: function(a) {
        wx.navigateTo({
            url: "teamMemberManage/teamMemberManage?teamId=" + this.data.teamId
        });
    },
    bindTeamAddAdminTap: function(a) {
        wx.navigateTo({
            url: "teamMemberAddAdmin/teamMemberAddAdmin?teamId=" + this.data.teamId
        });
    },
    bindSettingTap: function(a) {
        wx.navigateTo({
            url: "teamSetting/teamSetting?teamId=" + this.data.teamId
        });
    },
    bindDateChange: function(a) {
        console.log("picker发送选择改变，携带值为", a.detail);
        var t = a.detail.timepoint, e = a.detail.date;
        wx.navigateTo({
            url: "/pages/teamHome/teamHome?teamId=" + this.data.teamId + "&time=" + t + "&date=" + e
        });
    },
    onLoad: function(t) {
        var e = wx.getStorageSync(a.storage.meInfo);
        console.log(e), this.setData({
            teamId: e.teamId,
            teamName: e.teamName,
            teamAdmin: e.teamAdmin
        }), this.loadData(), this.loadTeamcheduleData();
    },
    onReady: function() {},
    onShow: function() {
        var t = wx.getStorageSync(a.storage.teamInfo);
        this.showTeamData(t);
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {}
});